﻿using UnityEngine;
using System;
using System.Collections;
using System.Collections.Generic;
using VoxelBlock;using Vector3Int = VoxelBlock.Vector3Int;
using VoxelBlock.VoxelBlock3D;

public class ProxyOperation
{
    HistoryRecordAPI<SerializeVoxelDatas, VoxelCategories.Operation> drawHistoryRecord;

    public void Clear()
    {
        drawHistoryRecord.Clear();
    }

    public ProxyOperation(HistoryRecordAPI<SerializeVoxelDatas, VoxelCategories.Operation> nowHistoryRecord)
    {
        this.drawHistoryRecord = nowHistoryRecord;
    }

    public void Write(VoxelCategories.Operation a_Operation, SerializeVoxelDatas a_frontUVList, SerializeVoxelDatas a_breakUVList)
    {
        drawHistoryRecord.Write(a_Operation, a_frontUVList, a_breakUVList);
    }

    public void Write(VoxelCategories.Operation a_Operation, IEnumerable<Vector3Int> frontUVList, IEnumerable<Vector3Int> breakUVList)
    {
        SerializeVoxelDatas frontDatas = new SerializeVoxelDatas(frontUVList);
        SerializeVoxelDatas breakDatas = new SerializeVoxelDatas(breakUVList);
        Write(a_Operation, frontDatas, breakDatas);
    }
    public void Write(VoxelCategories.Operation operation, IEnumerable<SimpleVoxel> frontUVList, IEnumerable<SimpleVoxel> breakUVList)
    {
        SerializeVoxelDatas frontDatas = new SerializeVoxelDatas(frontUVList);
        SerializeVoxelDatas breakDatas = new SerializeVoxelDatas(breakUVList);
        Write(operation, frontDatas, breakDatas);
    }

    public HistoryRecordAPI<SerializeVoxelDatas, VoxelCategories.Operation>.RecordData Revoke()
    {
        return drawHistoryRecord.Revoke();
    }

    public HistoryRecordAPI<SerializeVoxelDatas, VoxelCategories.Operation>.RecordData BackRevoke()
    {
        return drawHistoryRecord.BackRevoke();
    }
    public HistoryRecordAPI<SerializeVoxelDatas, VoxelCategories.Operation> GetHistoryRecord()
    {
        return drawHistoryRecord;
    }

    public int GetPointer()
    {
        return drawHistoryRecord.Pointer;
    }
    public void SetPointer(int pointer)
    {
        drawHistoryRecord.SetPointer(pointer);
    }

    public struct HistoryRecordData
    {
        VoxelCategories.Operation operation;
        SerializeVoxelDatas breakData;
        SerializeVoxelDatas frontData;
        public HistoryRecordData(VoxelCategories.Operation operation, SerializeVoxelDatas breakData, SerializeVoxelDatas frontData)
        {
            this.operation = operation;
            this.breakData = breakData;
            this.frontData = frontData;
        }
    }





}
